/**
 * @author 雷明浩
 * @date 2025/5/29 10:41
 */
public class SwapPairs {
    // leetcode 两两交换链表中的节点
    // https://leetcode.cn/problems/swap-nodes-in-pairs/?envType=study-plan-v2&envId=top-100-liked
    public ListNode swapPairs(ListNode head) {
        if (head == null || head.next == null) return head;
        ListNode nextCur = swapPairs(head.next.next);
        ListNode headNext = head.next;
        headNext.next = head;
        head.next = nextCur;
        return headNext;
    }
}